package com.natasha.pins.component.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;


public class DBHandler{
	
	private DBHelper dbHelper;
	private SQLiteDatabase connection;
	private final Context context;
	
	public DBHandler(Context context){
		this.context = context;
		dbHelper = new DBHelper(context);
	}
	
	private void open() throws android.database.SQLException{
		connection = dbHelper.getWritableDatabase();
	}
	
	public void close(){
		if( connection!= null){
			connection.close();
			connection = null;
		}
	}

	public SQLiteDatabase getConnection() {
		if( connection == null )
			open();
		return connection;
	}

}
